<template>
  <a-modal
    :visible="visible"
    title="成绩单"
    :width="900"
    :bodyStyle="{
      height: '500px',
      overflow: 'auto'
    }"
    @cancel="() => { $emit('cancel') }"
  >
    <detail-list :col="3">
      <detail-list-item :term="$t('key.xh')">{{ detail.xsxh }}</detail-list-item>
      <detail-list-item :term="$t('key.name')">{{ detail.xm }}</detail-list-item>
      <detail-list-item :term="$t('key.nj')">{{ detail.ksnj }}</detail-list-item>
      <detail-list-item :term="$t('key.xn')">{{ detail.ksxn }}</detail-list-item>
      <detail-list-item :term="$t('key.xq')">{{ detail.ksxqmc }}</detail-list-item>
      <detail-list-item :term="$t('key.kcmc')">{{ detail.kcmc }}</detail-list-item>
      <detail-list-item :term="$t('key.ksxz')">{{ detail.ksxzmc }}</detail-list-item>
      <detail-list-item :term="$t('key.kslb')">{{ detail.kslbmc }}</detail-list-item>
      <detail-list-item :term="$t('key.cj')">{{ detail.kscj }}</detail-list-item>
      <detail-list-item :term="$t('key.cjlx')">{{ detail.cjlxmc }}</detail-list-item>
      <detail-list-item :term="$t('key.cjzt')">{{ detail.cjztmc }}</detail-list-item>
      
    </detail-list>
    <div slot="footer">
      <a-button v-if="!isCredit" @click="exportPrint(0)" type="primary">打印中文成绩单</a-button>
      <a-button v-if="!isCredit" @click="exportPrint(1)" type="primary">打印英文成绩单</a-button>
      <a-button @click="() => { $emit('cancel') }">关闭</a-button>
    </div>
  </a-modal>
</template>

<script>
import DetailList from '~/tool/DetailList'
const DetailListItem = DetailList.Item

export default {
  props: ['visible', 'isCredit'],
  components: {DetailList, DetailListItem},
  data () {
    return {
      detail: {},
      columns: [
        {
          title: '序号',
          scopedSlots: { customRender: 'serial' }
        },
        {
          title: '课程名称',
          dataIndex: 'kcmc'
        },
        {
          title: '学分',
          dataIndex: 'xf',
          scopedSlots: { customRender: 'xf' }
        },
        {
          title: '成绩',
          dataIndex: 'kscj'
        },
        {
          title: '所属专业',
          dataIndex: 'sszymc'
        },
        {
          title: '修课状态',
          dataIndex: 'xkztmc'
        }
      ]
    }
  },
  methods: {
    exportPrint(en) {
      console.log(this.detail)
      let api = en ? '/teacherClient/kccj/xscjywPrint' : '/teacherClient/kccj/xscjPrint'
      this.$downloadPdf(api, { xh: this.detail.xsxh}, this.detail.xsxh + '_' + this.detail.xm + '成绩单.pdf')
    }
  }
}
</script>

<style>

</style>
